<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
		pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page import="com.github.pagehelper.PageInfo"%>
<%@ page import="student.beans.Student"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>学生信息</title>
<%
	pageContext.setAttribute("APP_PATH", request.getContextPath());
%>
<meta name="viewport"
		content="width=device-width,initial-scale=1,user-scalable=no" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" type="text/css"
		href="${APP_PATH}/bootstrap3/css/bootstrap.css">
<link rel="stylesheet" type="text/css"
		href="${APP_PATH}/bootstrap3/font-awesome-4.7.0/css/font-awesome.css" />
</head>
<body>
	<input type="hidden" name="itemPram" value="${item}">
	<input type="hidden" name="termPram" value="${term}">
		<div class="container">
				<div class="row well">
						<div class="col-md-4 col-md-offset-5">
								<h1>学生信息</h1>
						</div>
				</div>
				<div class="row">
						<div class="col-md-9 ">
								<div class="col-md-6">
										<div class="input-group">
												<div class="input-group-btn">
														<button type="button"
																class="btn btn-default dropdown-toggle"
																data-toggle="dropdown" aria-haspopup="true"
																aria-expanded="false">
																choose <span class="caret"></span>
														</button>
														<ul class="dropdown-menu">
																<li><a>Id</a></li>
																<li><a>name</a></li>
																<li><a>phone</a></li>
														</ul>
												</div>
												<form class="navbar-form navbar-left" action="${APP_PATH}/search" method="post">
														<input type="text" class="form-control" placeholder="Search" name="term">
														<input type="hidden" name="item" value="Id">
														<button type="submit" class="btn btn-default">Submit</button>
												</form>
										</div>
								</div>
						</div>
						<div class="col-md-3 ">
								<button class="btn btn-primary">
										<span></span>新增
								</button>
								<button class="btn btn-danger">
										<span></span>删除
								</button>
						</div>
				</div>
				<br>
				<div class="row">
						<table class="table table-hover">
								<tr>
										<th><span class="fa fa-check-square"></span></th>
										<th>学号</th>
										<th>姓名</th>
										<th>年龄</th>
										<th>性别</th>
										<th>电话</th>
										<th>操作</th>
								</tr>
								<c:forEach items="${pageInfo.list}" var="stu">
										<tr>
												<th><input type="checkbox" name="checks"></th>
												<th>${stu.stuId}</th>
												<th>${stu.stuName}</th>
												<th>${stu.age}</th>
												<c:if test="${stu.gender == 109}">
														<th>男</th>
												</c:if>
												<c:if test="${stu.gender != 109}">
														<th>女</th>
												</c:if>
												<th>${stu.phone}</th>
												<th><button class="btn btn-primary btn-sm">
																<span class="glyphicon glyphicon-pencil"
																		aria-hidden="true"></span> 编辑
														</button>
														<button class="btn btn-danger btn-sm">
																<span class="glyphicon glyphicon-trash"
																		aria-hidden="true"></span> 删除
														</button></th>
										</tr>
								</c:forEach>
						</table>
				</div>
				<div class="row">
						<div class="col-md-4 col-md-offset-5">
								当前${pageInfo.pageNum}页 , 共${pageInfo.pages}页,
								总共${pageInfo.total}条记录</div>
				</div>
				<div class="row">
						<div class="col-md-4 col-md-offset-8">
								<nav aria-label="...">
										<ul class="pagination">
												<li><a href="1"
														aria-label="Previous"><span aria-hidden="true">首页</span></a></li>
												<c:if test="${pageInfo.hasPreviousPage }">
														<li><a
																href="${pageInfo.pageNum-1}"
																aria-label="Previous"> <span aria-hidden="true">&laquo;</span>
														</a></li>
												</c:if>
												<c:forEach items="${pageInfo.navigatepageNums}" var="pageNo">
														<c:if test="${pageNo==pageInfo.pageNum}">
																<li class="active"><a href="#">${pageNo}</a></li>
														</c:if>
														<c:if test="${pageNo!=pageInfo.pageNum}">
																<li><a
																		href="${pageNo}">${pageNo}</a></li>
														</c:if>
												</c:forEach>
												<c:if test="${pageInfo.hasNextPage}">
														<li><a
																href="${pageInfo.pageNum+1}"
																aria-label="Previous"> <span aria-hidden="true">&raquo;</span>
														</a></li>
												</c:if>
												<li><a
														href="${pageInfo.lastPage}"
														aria-label="Previous"><span aria-hidden="true">末页</span></a></li>
										</ul>
								</nav>
						</div>
				</div>
		</div>
		<script type="text/javascript"
				src="${APP_PATH}/bootstrap3/jquery.min.js"></script>
		<script type="text/javascript"
				src="${APP_PATH}/bootstrap3/js/bootstrap.js"></script>
		<script type="text/javascript"
				src="${APP_PATH}/bootstrap3/js/holder.js"></script>
		<script type="text/javascript"
				src="${APP_PATH}/bootstrap3/js/html5shiv.min.js"></script>
		<script type="text/javascript"
				src="${APP_PATH}/bootstrap3/js/css3-mediaqueries.js"></script>
		<script type="text/javascript" src="${APP_PATH}/bootstrap3/js/respond.min.js"></script>
		<script type="text/javascript" src="${APP_PATH}/myjs/stuList.js"></script>
		<script type="text/javascript">		
		$("button[type='submit']").click(function() {
			var intext = $("form>input[type='text']").val();
			var inputh = $("form>input[type='hidden']").val();
			if (inputh == "Id") {
				var reg = /^[0-9]+$/;
			} else if (inputh == "name") {
				var reg = /^(\w+|[\u2E80-\u9FFF]+)$/;
			} else if (inputh == "phone") {
				var reg = /^[\d]{5,20}$/;
			}
			if (!reg.test(intext)) {
				alert("输入的条件不合法");				
				return false;
			}
			$("body>input[name='itemPram']").val(inputh);
			$("body>input[name='termPram']").val(intext);
		});
		$("ul[class='pagination']>li>a").click(function(){
			var item=$("body>input[name='itemPram']").val();
			var term=$("body>input[name='termPram']").val();
			var pageNo=$(this).href();
			var url="${APP_PATH}/listStudents?pageNo="+pageNo;
			if(item!=null&&term!=null){
				url="${APP_PATH}/search?pageNo="+pageNo;
			}
			//alert($(this).text());
			
		});
		
		</script>
</body>

</html>